//request.js 专门处理请求
// cart.js 放购物车请求
// goods.js 商品的请求
import http from './http.js'
import api from './api.js'
//获取商品
export function getGoods(classify_id) {
    return http({
        method: "GET",
        url: api.getGoods,
        params: {
            project_id: 7,
            limit: 100,
            classify_id,
        }
    })
}
//轮播图
export function getCarousel() {
    return http({
        method: "GET",
        url: api.getCarousel,
        params: {
            project_id: 7,
            limit: 100
        }
    })
}
//注册
export function getRegister(data) {
    return http({
        method: "POST",
        url: api.getRegister,
        data: data
    })
}
//登录
export function getLogin(data) {
    return http({
        method: "POST",
        url: api.getLogin,
        data: data
    })
}
//获取用户信息
export function getUserInfo() {
    return http({
        method: "GET",
        url: api.getUserInfo,
    })
}
//退出
export function getLoginOut() {
    return http({
        method: "POST",
        url: api.getLoginOut
    })
}
//获取商品详情
export function getProductDetail(id) {
    return http({
        method: "GET",
        url: api.getGoods + `/${id}`,

    })
}
//添加购物车
export function getAddCart(data) {
    return http({
        method: "POST",
        url: api.getAddCart,
        data
        // data: {
        //     project_id: 7,
        //     id
        // }
    })
}
//获取购物车信息
export function getCartInfo() {
    return http({
        method: "GET",
        url: api.getCartInfo,
        params: {
            project_id: 7,
        }

    })
}
//更新购物车信息
export function updateCartInfo(id, data) {
    return http({
        method: "PUT",
        url: api.getCartInfo + `/${id}`,
        data
    })
}
//删除购物车商品信息
export function delCart(id) {
    return http({
        method: "DELETE",
        url: api.getCartInfo + `/${id}`,

    })
}
//获取城市
export function getCity() {
    return http({
        method: "GET",
        url: api.getCity,


    })
}
//获取地址
export function getAddress() {
    return http({
        method: "GET",
        url: api.getAddress
    })
}
//修改地址信息
export function editAddress(id, data) {
    return http({
        method: "PUT",
        url: api.getAddress + `/${id}`,
        data
    })
}
//删除地址信息
export function delAddress(id) {
    return http({
        method: "DELETE",
        url: api.getAddress + `/${id}`,

    })
}
//增加地址
export function addAddress(data) {
    return http({
        method: "POST",
        url: api.getAddress,
        data

    })
}
//添加订单
export function AddOrder(data) {
    return http({
        method: "POST",
        url: api.addOrder,
        data

    })
}
//获取订单信息
export function getOrder(id) {
    return http({
        method: "GET",
        url: api.getOrder + `/${id}`,


    })
}
//获取所有订单
export function getOrderAll() {
    return http({
        method: "GET",
        url: api.getOrder,
        params: {
            project_id: 7,
        }
    })
}